﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Odyssey.Controls;
using Odyssey.Controls.Classes;
using System.Windows.Controls.Primitives;
using WpfELearningAuthoringTool;
using System.Xml;
using ScormModel;
using ScormModel.Question;
using ScormModel.HtmlBuilder;
namespace WpfELearningAuthoringTool
{
    class ContextMenuAction
    {
        TreeView tvMain;
        ImsManifest imsmanifest;
        StackPanel container;
        RibbonBarRegion.RibbonBarHeader parentChild;
        string currentDirectory;
        WebBrowser browser;
        public string CurrentDirectory
        {
            get { return this.currentDirectory; }
            set { this.currentDirectory = value; }
        }
        public WebBrowser WebBrowser
        {
            get { return this.browser; }
            set { this.browser = value; }
        }
        public StackPanel Container
        {
            get { return this.container; }
            set { this.container = value; }
        }
        public ImsManifest Imsmanifest
        {
            get { return this.imsmanifest; }
            set { this.imsmanifest = value; }
        }
        public TreeView MainTree
        {
            get { return this.tvMain; }
            set { this.tvMain = value; }
        }
        public RibbonBarRegion.RibbonBarHeader Parent
        {
            get { return this.parentChild; }
            set { this.parentChild = value; }
        }
        #region None Template
        /*--------------------------Begin None Template--------------------------*/
        public void AddModuleForNoneTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Please enter module name";
            im.Action = "AddModule";
            im.ShowDialog();
        }
        public void AddLessonForNoneTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Please enter lesson name";
            im.Action = "AddLesson";
            im.ShowDialog();
        }
        public void AddQuestionForNoneTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Please enter lesson name";
            im.Action = "AddQuestion";
            im.ShowDialog();
        }
        public void RenameNodeForNoneTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Enter new name";
            im.Action = "Rename";
            im.ShowDialog();
        }
        public void RenameCourseForNoneTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Enter new name";
            im.Action = "RenameCourse";
            im.ShowDialog();
        }
        public void RemoveItemForNoneTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            TreeViewProcessing tcp = new TreeViewProcessing();
            tcp.Imsmanifest = imsmanifest;
            ManifestProcessing mp = new ManifestProcessing(imsmanifest);
            if (mp.removeItemForNoneTemplate(temp) )
            {
                tcp.removeTreeViewItem(temp);
                imsmanifest.ListTitleHistory.Remove(mp.getNameOfTreeViewItem(temp));
                MessageBox.Show("Delete Success");
            }
            else {
                MessageBox.Show("Delete Fail");
            }
        }
        public void AddIntoForNoneTemplate(object sender, RoutedEventArgs e)
        {
           
        }
        public void AddLessonContentForNoneTemplate(object sender, RoutedEventArgs e)
        {
           
        }
        public void AddQuestionContentForNoneTemplate(object sender, RoutedEventArgs e)
        {
            QuestionTypeDialog qtd = new QuestionTypeDialog();
            qtd.Owner = parentChild;
            qtd.ParentChild = parentChild;
            qtd.CurrentDirectory = currentDirectory;
            qtd.WebBrowser = browser;
            qtd.Imsmanifest = imsmanifest;
            qtd.ShowDialog();
        }
        /*---------------------------End None Template-----------------------------*/
        #endregion
        #region Custom Template
        public void AddModuleForCustomTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Please enter module name";
            im.Action = "AddModule";
            im.ShowDialog();
        }
        public void AddLessonForCustomTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Please enter lesson name";
            im.Action = "AddLesson";
            im.ShowDialog();
        }
        public void AddQuestionForCustomTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Please enter lesson name";
            im.Action = "AddQuestion";
            im.ShowDialog();
        }
        public void AddTestForCustomTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Please enter test name";
            im.Action = "AddTest";
            im.ShowDialog();
        }
        public void AddExamForCustomTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Please enter exam name";
            im.Action = "AddExam";
            im.ShowDialog();
        }
        public void RenameNodeForCustomTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Enter new name";
            im.Action = "Rename";
            im.ShowDialog();
        }
        public void RenameCourseForCustomTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Enter new name";
            im.Action = "RenameCourse";
            im.ShowDialog();
        }
        public void RemoveItemForCustomTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            TreeViewProcessing tcp = new TreeViewProcessing();
            tcp.Imsmanifest = imsmanifest;
            ManifestProcessing mp = new ManifestProcessing(imsmanifest);
            if (mp.removeItemForCustomTemplate(temp))
            {
                tcp.removeTreeViewItem(temp);
                imsmanifest.ListTitleHistory.Remove(mp.getNameOfTreeViewItem(temp));
                MessageBox.Show("Delete Success");
            }
            else
            {
                MessageBox.Show("Delete Fail");
            }
        }
        public void ConfigSequencing(object sender, RoutedEventArgs e)
        {
            ManifestProcessing mp = new ManifestProcessing(imsmanifest);
            string selectItemName = mp.getNameOfTreeViewItem((TreeViewItem)tvMain.SelectedItem);
            Item selectedItem = mp.findItemByName(selectItemName);
            SequencingOptionDialog sod = new SequencingOptionDialog();
            sod.SelectedItem = selectedItem;
            sod.Owner = parentChild;
            sod.Imsmanifest = imsmanifest;
            sod.ShowDialog();
        }
        public void ConfigCourseSequencing(object sender, RoutedEventArgs e)
        {
            ManifestProcessing mp = new ManifestProcessing(imsmanifest);
            string selectItemName = mp.getNameOfTreeViewItem((TreeViewItem)tvMain.SelectedItem);
            Organization selectedItem = mp.findOrganizationByName(selectItemName);
            SequencingCourseOptionDialog sod = new SequencingCourseOptionDialog();
            sod.SelectedItem = selectedItem;
            sod.Owner = parentChild;
            sod.Imsmanifest = imsmanifest;
            sod.ShowDialog();
        }
        public void ConfigTimeLimit(object sender, RoutedEventArgs e)
        {
            ManifestProcessing mp = new ManifestProcessing(imsmanifest);
            string selectItemName = mp.getNameOfTreeViewItem((TreeViewItem)tvMain.SelectedItem);
            Item selectedItem = mp.findItemByName(selectItemName);
            TimeLimitConfiguration tmc = new TimeLimitConfiguration();
            tmc.SelectedItem = selectedItem;
            tmc.Owner = parentChild;
            tmc.ShowDialog();
        }
        public void AddQuestionContentForCustomTemplate(object sender, RoutedEventArgs e)
        {
            QuestionTypeDialog qtd = new QuestionTypeDialog();
            qtd.Owner = parentChild;
            qtd.ParentChild = parentChild;
            qtd.CurrentDirectory = currentDirectory;
            qtd.WebBrowser = browser;
            qtd.Imsmanifest = imsmanifest;
            qtd.ShowDialog();
        }
        public void AddTestContentForCustomTemplate(object sender, RoutedEventArgs e)
        {
            ExamDialog qtd = new ExamDialog();
            qtd.Owner = parentChild;
            qtd.ParentChild = parentChild;
            qtd.CurrentDirectory = currentDirectory;
            qtd.WebBrowser = browser;
            qtd.Imsmanifest = imsmanifest;
            qtd.ShowDialog();
        }
        #endregion
        #region Linear Template
        /*---------------------------Begin Linear Template-------------------------*/
        public void AddModuleForLinearTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Please enter module name";
            im.Action = "AddModule";
            im.ShowDialog();
        }
        public void AddLessonForLinearTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Please enter lesson name";
            im.Action = "AddLesson";
            im.ShowDialog();
        }
        public void AddQuestionForLinearTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Please enter lesson name";
            im.Action = "AddQuestion";
            im.ShowDialog();
        }
        public void RenameNodeForLinearTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Enter new name";
            im.Action = "Rename";
            im.ShowDialog();
        }
        public void RenameCourseForLinearTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Enter new name";
            im.Action = "RenameCourse";
            im.ShowDialog();
        }
        public void RemoveItemForLinearTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            TreeViewProcessing tcp = new TreeViewProcessing();
            tcp.Imsmanifest = imsmanifest;
            ManifestProcessing mp = new ManifestProcessing(imsmanifest);
            if (mp.removeItemForLinearTemplate(temp))
            {
                 tcp.removeTreeViewItem(temp);
                imsmanifest.ListTitleHistory.Remove(mp.getNameOfTreeViewItem(temp));
                MessageBox.Show("Delete Success");
            }
            else
            {
                MessageBox.Show("Delete Fail");
            }
        }
        public void AddIntoForLinearTemplate(object sender, RoutedEventArgs e)
        {
            
        }
        public void AddLessonContentForLinearTemplate(object sender, RoutedEventArgs e)
        {
           
        }
        public void AddQuestionContentForLinearTemplate(object sender, RoutedEventArgs e)
        {
            QuestionTypeDialog qtd = new QuestionTypeDialog();
            qtd.Owner = parentChild;
            qtd.ParentChild = parentChild;
            qtd.CurrentDirectory = currentDirectory;
            qtd.WebBrowser = browser;
            qtd.Imsmanifest = imsmanifest;
            qtd.ShowDialog();
        }
        /*---------------------------End Linear Template---------------------------*/
        #endregion
        #region Linear Choice Template
        /*---------------------------Begin Linear Choice Template-------------------------*/
        public void AddModuleForLinearChoiceTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Please enter module name";
            im.Action = "AddModule";
            im.ShowDialog();
        }
        public void AddQuestionForLinearChoiceTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Please enter lesson name";
            im.Action = "AddQuestion";
            im.ShowDialog();
        }
        public void AddLessonForLinearChoiceTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Please enter lesson name";
            im.Action = "AddLesson";
            im.ShowDialog();
        }
        public void RemoveItemForLinearChoiceTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            TreeViewProcessing tcp = new TreeViewProcessing();
            tcp.Imsmanifest = imsmanifest;
            ManifestProcessing mp = new ManifestProcessing(imsmanifest);
            if (mp.removeItemForLinearChoiceTemplate(temp))
            {
                 tcp.removeTreeViewItem(temp);
                imsmanifest.ListTitleHistory.Remove(mp.getNameOfTreeViewItem(temp));
                MessageBox.Show("Delete Success");
            }
            else
            {
                MessageBox.Show("Delete Fail");
            }
        }
        public void RenameNodeForLinearChoiceTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Enter new name";
            im.Action = "Rename";
            im.ShowDialog();
        }
        public void RenameCourseForLinearChoiceTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Enter new name";
            im.Action = "RenameCourse";
            im.ShowDialog();
        }
        public void AddIntoForLinearChoiceTemplate(object sender, RoutedEventArgs e)
        {
            
        }
        public void AddLessonContentForLinearChoiceTemplate(object sender, RoutedEventArgs e)
        {
           
        }
        public void AddQuestionContentForLinearChoiceTemplate(object sender, RoutedEventArgs e)
        {
            QuestionTypeDialog qtd = new QuestionTypeDialog();
            qtd.Owner = parentChild;
            qtd.ParentChild = parentChild;
            qtd.CurrentDirectory = currentDirectory;
            qtd.WebBrowser = browser;
            qtd.Imsmanifest = imsmanifest;
            qtd.ShowDialog();
        }
        /*---------------------------End Linear Choice Template-------------------------*/
        #endregion
        #region Constrained Choice Template
        /*---------------------------Begin Constrained Choice Template-------------------------*/
        public void AddModuleForConstrainedChoiceTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Please enter module name";
            im.Action = "AddModule";
            im.ShowDialog();
        }
        public void AddQuestionForConstrainedChoiceTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Please enter lesson name";
            im.Action = "AddQuestion";
            im.ShowDialog();
        }
        public void AddLessonForConstrainedChoiceTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Please enter lesson name";
            im.Action = "AddLesson";
            im.ShowDialog();
        }
        public void RemoveItemForConstrainedChoiceTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            TreeViewProcessing tcp = new TreeViewProcessing();
            tcp.Imsmanifest = imsmanifest;
            ManifestProcessing mp = new ManifestProcessing(imsmanifest);
            if (mp.removeItemForLinearChoiceTemplate(temp))
            {
                tcp.removeTreeViewItem(temp);
                imsmanifest.ListTitleHistory.Remove(mp.getNameOfTreeViewItem(temp));
                MessageBox.Show("Delete Success");
            }
            else
            {
                MessageBox.Show("Delete Fail");
            }
        }
        public void RenameNodeForConstrainedChoiceTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Enter new name";
            im.Action = "Rename";
            im.ShowDialog();
        }
        public void RenameCourseForConstrainedChoiceTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Enter new name";
            im.Action = "RenameCourse";
            im.ShowDialog();
        }
        public void AddIntoForConstrainedChoiceTemplate(object sender, RoutedEventArgs e)
        {
           
        }
        public void AddLessonContentForConstrainedChoiceTemplate(object sender, RoutedEventArgs e)
        {
           
        }
        public void AddQuestionContentForConstrainedChoiceTemplate(object sender, RoutedEventArgs e)
        {
            QuestionTypeDialog qtd = new QuestionTypeDialog();
            qtd.Owner = parentChild;
            qtd.ParentChild = parentChild;
            qtd.CurrentDirectory = currentDirectory;
            qtd.WebBrowser = browser;
            qtd.Imsmanifest = imsmanifest;
            qtd.ShowDialog();
        }
        /*---------------------------End Constrained Choice Template-------------------------*/
        #endregion
        #region Linear Control Template
        /*---------------------------Begin Linear Control Template-------------------------*/
        public void AddModuleForLinearControlTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Please enter module name";
            im.Action = "AddModule";
            im.ShowDialog();
        }
        public void AddLessonForLinearControlTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Please enter lesson name";
            im.Action = "AddLesson";
            im.ShowDialog();
        }
        public void AddQuesionForLinearControlTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Please enter question name";
            im.Action = "AddQuestion";
            im.ShowDialog();
        }
        public void RenameNodeForLinearControlTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Enter new name";
            im.Action = "Rename";
            im.ShowDialog();
        }
        public void RenameCourseForLinearControlTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Enter new name";
            im.Action = "RenameCourse";
            im.ShowDialog();
        }
        public void RemoveItemForLinearControlTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            TreeViewProcessing tcp = new TreeViewProcessing();
            tcp.Imsmanifest = imsmanifest;
            ManifestProcessing mp = new ManifestProcessing(imsmanifest);
            if (mp.removeItemForLinearControlTemplate(temp) && tcp.removeTreeViewItem(temp))
            {
                MessageBox.Show("Delete Success");
            }
            else
            {
                MessageBox.Show("Delete Fail");
            }
        }
        public void AddIntoForLinearControlTemplate(object sender, RoutedEventArgs e)
        {
            
        }
        public void AddLessonContentForLinearControlTemplate(object sender, RoutedEventArgs e)
        {
           
        }
        public void AddQuestionContentForLinearControlTemplate(object sender, RoutedEventArgs e)
        {
            QuestionTypeDialog qtd = new QuestionTypeDialog();
            qtd.Owner = parentChild;
            qtd.ParentChild = parentChild;
            qtd.CurrentDirectory = currentDirectory;
            qtd.WebBrowser = browser;
            qtd.Imsmanifest = imsmanifest;
            qtd.ShowDialog();
        }
        /*---------------------------End Linear Control Template---------------------------*/
        #endregion
        #region Competency Template
        /*---------------------------Begin Competency Template-------------------------*/
        public void AddModuleForCompetencyTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Please enter module name";
            im.Action = "AddModule";
            im.ShowDialog();
        }
        public void AddLessonForCompetencyTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Please enter lesson name";
            im.Action = "AddLesson";
            im.ShowDialog();
        }
        public void AddQuesionForCompetencyTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Please enter question name";
            im.Action = "AddQuestion";
            im.ShowDialog();
        }
        public void RenameNodeForCompetencyTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Enter new name";
            im.Action = "Rename";
            im.ShowDialog();
        }
        public void RenameCourseForCompetencyTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Enter new name";
            im.Action = "RenameCourse";
            im.ShowDialog();
        }
        public void RemoveModuleItemForCompetencyTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            TreeViewProcessing tcp = new TreeViewProcessing();
            tcp.Imsmanifest = imsmanifest;
            ManifestProcessing mp = new ManifestProcessing(imsmanifest);
            if (mp.removeItemForCompetencyTemplate(temp) && tcp.removeModuleForCompetencyTemplate(temp))
            {
                imsmanifest.ListTitleHistory.Remove(mp.getNameOfTreeViewItem(temp));
                MessageBox.Show("Delete Success");
            }
            else
            {
                MessageBox.Show("Delete Fail");
            }
        }
        public void RemoveItemForCompetencyTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            TreeViewProcessing tcp = new TreeViewProcessing();
            tcp.Imsmanifest = imsmanifest;
            ManifestProcessing mp = new ManifestProcessing(imsmanifest);
            if (mp.removeItemForCompetencyTemplate(temp))
            {
                tcp.removeTreeViewItem(temp);
                imsmanifest.ListTitleHistory.Remove(mp.getNameOfTreeViewItem(temp));
                MessageBox.Show("Delete Success");
            }
            else
            {
                MessageBox.Show("Delete Fail");
            }
        }
        public void AddIntoForCompetencyTemplate(object sender, RoutedEventArgs e)
        {
            
        }
        public void AddLessonContentForCompetencyTemplate(object sender, RoutedEventArgs e)
        {
          
        }
        public void AddQuestionContentForCompetencyTemplate(object sender, RoutedEventArgs e)
        {
            QuestionTypeDialog qtd = new QuestionTypeDialog();
            qtd.Owner = parentChild;
            qtd.ParentChild = parentChild;
            qtd.CurrentDirectory = currentDirectory;
            qtd.WebBrowser = browser;
            qtd.Imsmanifest = imsmanifest;
            qtd.ShowDialog();
        }
        public void AddTestContentForCompetencyTemplate(object sender, RoutedEventArgs e)
        {
            ExamCompetencyDialog qtd = new ExamCompetencyDialog();
            qtd.Owner = parentChild;
            qtd.ParentChild = parentChild;
            qtd.CurrentDirectory = currentDirectory;
            qtd.WebBrowser = browser;
            qtd.Imsmanifest = imsmanifest;
            qtd.ShowDialog();
        }
        /*---------------------------End Competency Template---------------------------*/
        #endregion
        #region Knowledge Paced Template
        /*---------------------------Begin Knowledge Paced Template-------------------------*/
        public void AddModuleForKnowledgePacedTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Please enter module name";
            im.Action = "AddModule";
            im.ShowDialog();
        }
        public void AddLessonForKnowledgePacedTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Please enter lesson name";
            im.Action = "AddLesson";
            im.ShowDialog();
        }
        public void AddQuesionForKnowledgePacedTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Please enter question name";
            im.Action = "AddQuestion";
            im.ShowDialog();
        }
        public void RenameNodeForKnowledgePacedTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Enter new name";
            im.Action = "Rename";
            im.ShowDialog();
        }
        public void RenameCourseForKnowledgePacedTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Enter new name";
            im.Action = "RenameCourse";
            im.ShowDialog();
        }
        //public void RemoveModuleItemForKnowledgePacedTemplate(object sender, RoutedEventArgs e)
        //{
        //    TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
        //    TreeViewProcessing tcp = new TreeViewProcessing();
        //    tcp.Imsmanifest = imsmanifest;
        //    ManifestProcessing mp = new ManifestProcessing(imsmanifest);
        //    if (mp.removeItemForCompetencyTemplate(temp) && tcp.removeModuleForCompetencyTemplate(temp))
        //    {
        //        MessageBox.Show("Delete Success");
        //    }
        //    else
        //    {
        //        MessageBox.Show("Delete Fail");
        //    }
        //}
        public void RemoveItemForKnowledgePacedTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            TreeViewProcessing tcp = new TreeViewProcessing();
            tcp.Imsmanifest = imsmanifest;
            ManifestProcessing mp = new ManifestProcessing(imsmanifest);
            if (mp.removeItemForKnowledgePacedTemplate(temp) )
            {
                tcp.removeTreeViewItem(temp);
                imsmanifest.ListTitleHistory.Remove(mp.getNameOfTreeViewItem(temp));
                MessageBox.Show("Delete Success");
            }
            else
            {
                MessageBox.Show("Delete Fail");
            }
        }
        public void AddQuestionContentForKnowledgePacedTemplate(object sender, RoutedEventArgs e)
        {
            QuestionTypeDialog qtd = new QuestionTypeDialog();
            qtd.Owner = parentChild;
            qtd.ParentChild = parentChild;
            qtd.CurrentDirectory = currentDirectory;
            qtd.WebBrowser = browser;
            qtd.Imsmanifest = imsmanifest;
            qtd.ShowDialog();
        }
        public void GenerateSummaryForKnowledgePacedTemplate(object sender, RoutedEventArgs e)
        {
            SummaryData sd = new SummaryData();
            ManifestProcessing mp = new ManifestProcessing(imsmanifest);
            sd.ListObjective = mp.getListObjective();
            HtmlDocument content = sd.CreateHtmlNode();
            browser.NavigateToString(content.HTML);
        }
        /*---------------------------End Knowledge Paced  Template-------------------------*/
        #endregion

        #region Knowledge Paced Reused Template
        /*---------------------------Begin Knowledge Paced Reused Template-------------------------*/
        public void AddModuleForKnowledgePacedReusedTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Please enter module name";
            im.Action = "AddModule";
            im.ShowDialog();
        }
        public void AddLessonForKnowledgePacedReusedTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Please enter lesson name";
            im.Action = "AddLesson";
            im.ShowDialog();
        }
        public void AddQuesionForKnowledgePacedReusedTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Please enter question name";
            im.Action = "AddQuestion";
            im.ShowDialog();
        }
        public void RenameNodeForKnowledgePacedReusedTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Enter new name";
            im.Action = "Rename";
            im.ShowDialog();
        }
        public void RenameCourseForKnowledgePacedReusedTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Enter new name";
            im.Action = "RenameCourse";
            im.ShowDialog();
        }
        public void RemoveItemForKnowledgePacedReusedTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            TreeViewProcessing tcp = new TreeViewProcessing();
            tcp.Imsmanifest = imsmanifest;
            ManifestProcessing mp = new ManifestProcessing(imsmanifest);
            if (mp.removeItemForKnowledgePacedTemplate(temp))
            {
                tcp.removeTreeViewItem(temp);
                imsmanifest.ListTitleHistory.Remove(mp.getNameOfTreeViewItem(temp));
                MessageBox.Show("Delete Success");
            }
            else
            {
                MessageBox.Show("Delete Fail");
            }
        }
        public void AddQuestionContentForKnowledgePacedReusedTemplate(object sender, RoutedEventArgs e)
        {
            QuestionTypeDialog qtd = new QuestionTypeDialog();
            qtd.Owner = parentChild;
            qtd.ParentChild = parentChild;
            qtd.CurrentDirectory = currentDirectory;
            qtd.WebBrowser = browser;
            qtd.Imsmanifest = imsmanifest;
            qtd.ShowDialog();
        }
        public void GenerateSummaryForKnowledgePacedReusedTemplate(object sender, RoutedEventArgs e)
        {
            SummaryData sd = new SummaryData();
            ManifestProcessing mp = new ManifestProcessing(imsmanifest);
            sd.ListObjective = mp.getListObjective();
            HtmlDocument content = sd.CreateHtmlNode();
            browser.NavigateToString(content.HTML);
        }
        /*---------------------------End Knowledge Paced Reused Template-------------------------*/
        #endregion

        #region Remediation Template
        public void AddModuleForRemediationTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.MainTree = tvMain;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Please enter module name";
            im.Action = "AddModule";
            im.ShowDialog();
        }
        public void AddLessonForRemediationTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Please enter lesson name";
            im.Action = "AddLesson";
            im.ShowDialog();
        }
        public void AddQuestionForRemediationTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Please enter lesson name";
            im.Action = "AddQuestion";
            im.ShowDialog();
        }
        public void RenameNodeForRemediationTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Enter new name";
            im.Action = "Rename";
            im.ShowDialog();
        }
        public void RenameCourseForRemediationTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            InputData im = new InputData();
            im.SelectedItem = temp;
            im.Imsmanifest = imsmanifest;
            im.LessonType.Content = "Enter new name";
            im.Action = "RenameCourse";
            im.ShowDialog();
        }
        public void RemoveItemForRemediationTemplate(object sender, RoutedEventArgs e)
        {
            TreeViewItem temp = (TreeViewItem)tvMain.SelectedItem;
            TreeViewProcessing tcp = new TreeViewProcessing();
            tcp.Imsmanifest = imsmanifest;
            tcp.MainTree = tvMain;
            ManifestProcessing mp = new ManifestProcessing(imsmanifest);
            if (mp.removeItemForRemediationTemplate(temp))
            {
                tcp.removeItemForRemediationTemplate(temp);
                imsmanifest.ListTitleHistory.Remove(mp.getNameOfTreeViewItem(temp));
                MessageBox.Show("Delete Success");
            }
            else
            {
                MessageBox.Show("Delete Fail");
            }
        }
        public void AddQuestionContentForRemediationTemplate(object sender, RoutedEventArgs e)
        {
            QuestionTypeDialog qtd = new QuestionTypeDialog();
            qtd.Owner = parentChild;
            qtd.ParentChild = parentChild;
            qtd.CurrentDirectory = currentDirectory;
            qtd.WebBrowser = browser;
            qtd.Imsmanifest = imsmanifest;
            qtd.ShowDialog();
        }
        #endregion
    }
}
